<!--
 * @Author: your name
 * @Date: 2021-10-07 14:34:34
 * @LastEditTime: 2022-02-13 16:30:26
 * @LastEditors: ke.xue
 * @Description: In User Settings Edit
 * @FilePath: \product-display\src\components\pageTop.vue
-->
<template>
  <div class="pageTop">
    <div class="welcome"><p>您好，欢迎进入苏州尤优家具有限公司官网！</p></div>
    <div class="pageTopImg" @click="toIndex">
      <div><img :src="pageTop" alt=""></div>
    </div>
    <!-- <div class="companyName">
      <div class="toHome"><img :src="bigLogo" alt=""></div>
      <div class="companyDesc">
        <p class="desc1">一家专业从事生产及销售防静电家具和办公家具的公司</p>
        <p class="desc2">致力为各类客户在办公环境方面塑造成功的企业形象</p>
      </div>
    </div> -->
    <div class="menuBox">
      <el-menu :default-active="activeIndex" active-text-color="#fff" text-color="#fff" mode="horizontal" class="menuList" router  @select="handleSelect">
        <template v-for="item in menuList">
          <el-submenu v-if="item.children" :index="item.path" :key="item.name" :popper-append-to-body="false" popper-class="submenuBox">
            <template slot="title">{{item.title}}</template>
            <el-menu-item v-for="(typeItem, index) in typeTree" :key="typeItem.id" :index="'/show/list?index=' + index + '&update=1'">{{typeItem.categoryName}}</el-menu-item>
          </el-submenu>
          <el-menu-item v-else :index="item.path" :key="item.name">{{item.title}}</el-menu-item>
        </template>
      </el-menu>
    </div>
    <Banner v-if="showBanner" />
  </div>
</template>

<script>
import Banner from '@/components/banner'
import { bigLogo, pageTop } from '@/assets/js/img.js'
import { mapGetters } from 'vuex'

export default {
  name: 'PageTop',
  components: {
    Banner
  },
  props: {
    active: {
      type: [String, Number],
      default: () => {}
    },
    showBanner: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      bigLogo,
      pageTop,
      activeIndex: '/show/index',
      menuList: [
        {
          path: '/show/index',
          name: 'index',
          title: '网站首页'
        },
        {
          path: '/show/list',
          name: 'list',
          title: '产品中心',
          children: true
        },
        {
          path: '/show/about',
          name: 'about',
          title: '关于我们'
        }
      ]
    }
  },
  computed: {
    ...mapGetters([
      'typeTree'
    ])
  },
  watch: {
    active (val) {
      this.activeIndex = val
    }
  },
  mounted () {
    this.activeIndex = this.$route.path
  },
  methods: {
    toIndex () {
      this.$router.push({
        path: '/show/index'
      })
    },
    handleSelect (val) {
      // console.log(val, 'handleSelect')
    }
  }
}
</script>

<style lang="less" scoped>
.pageTop {
  width: 100vw;
  min-width: 1200px;
  .welcome {
    font-size: 12px;
    line-height: 30px;
    background-color: #f7f7f7;
    border-bottom: 1px solid #DFDFDF;
    p {
      margin: 0 auto;
      width: 1200px;
    }
  }
  .pageTopImg>div {
    margin: 0 auto;
    width: 1200px;
    font-size: 0;
  }
  .companyName {
    display: flex;
    margin: 0 auto;
    padding: 10px 0;
    width: 1200px;
    .toHome {
      width: 300px;
    }
    .companyDesc {
      margin-top: 24px;
      padding-left: 20px;
      .desc1 {
        font-size: 20px;
        line-height: 30px;
      }
      .desc2 {
        font-size: 14px;
        line-height: 24px;
      }
    }
  }
  .menuBox {
    background: #5ca0d2;
    .menuList {
      margin: 0 auto;
      border: none;
      width: 1200px;
      background: #5ca0d2;
      .el-menu-item {
        width: 200px;
        text-align: center;
        &.is-active {
          border: 0;
        }
        &:hover, &.is-active {
          background-color: #999999;
        }
      }
      .el-submenu {
        width: 200px;
        text-align: center;
        &.is-opened {
          background-color: #999999;
        }
      }
      .submenuBox {
        background-color: #5ca0d2 !important;
        .el-menu-item {
          background: #5ca0d2;
          &:hover, &.is-active {
            background-color: #999999;
          }
        }
      }
    }
  }
}
</style>
